<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>修改个人信息</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <script src="/js/jquery.min.js"></script>
    <style>
        .container { margin-top: 20px; }
        .form-group { margin-bottom: 15px; }
    </style>
</head>
<body>
<div class="container">
    <h2>修改个人信息</h2>
    <form id="editInfoForm">
        <%-- Example field: Allergy History --%>
        <div class="form-group">
            <label for="allergyHistory">过敏史</label>
            <textarea class="form-control" id="allergyHistory" name="allergyHistory" rows="3"></textarea>
        </div>
        <%-- Add other editable fields here --%>

        <button type="submit" class="btn btn-primary">保存修改</button>
    </form>
</div>

<script>
$(function(){
    // TODO: Implement fetching current user info via AJAX
    // Example placeholder:
    /*
    $.ajax({
        url: '/api/patient/personalInfo', // Replace with your actual API endpoint to get info
        type: 'GET',
        success: function(res){
            if(res.code === 0 && res.data){
                $('#allergyHistory').val(res.data.allergyHistory);
                // ... populate other fields
            }
        }
    });
    */

    // TODO: Implement form submission via AJAX
    $('#editInfoForm').submit(function(event){
        event.preventDefault(); // Prevent default form submission

        var formData = {
            allergyHistory: $('#allergyHistory').val()
            // ... collect other field data
        };

        /*
        $.ajax({
            url: '/api/patient/updatePersonalInfo', // Replace with your actual API endpoint to update info
            type: 'POST',
            contentType: 'application/json',
            data: JSON.stringify(formData),
            success: function(res){
                if(res.code === 0){
                    alert('个人信息修改成功！');
                    // Redirect back to medical record detail page or show success message
                } else {
                    alert('个人信息修改失败：' + res.message);
                }
            },
            error: function(){
                alert('请求失败，请稍后重试。');
            }
        });
        */
         alert('保存修改功能待实现，提交的数据：' + JSON.stringify(formData)); // Placeholder alert
    });
});
</script>
</body>
</html> 